import {defineStore} from 'pinia'
interface UserType{
    name:string
    age:number
    job:string
}
const useUserStore=defineStore('user',{
    state(){
        return{
            name:'张三丰',
            age:120,
            job:'掌门'
        }
    },
    actions:{
        modifyUserInfo(name:string,age:number,job:string){
            this.name=name
            this.age=age
            this.job=job
        }
    },
    getters:{
        getName:(state:UserType)=>state.name,
        getAge:(state:UserType)=>state.age,
        getJob:(state:UserType)=>state.job,
        getUserInfo:(state)=>`姓名:${state.name}\n年龄:${state.age}\n职位:${state.job}`
    },
    persist:{
        enabled:true,
        strategies:[
            {
                key:'gilekey',
                storage:localStorage,
                paths:['name','job']
            }
        ]
    }
})
export default useUserStore